#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
//    QColorDialog* dialog = new QColorDialog(this);
//    dialog->setAttribute(Qt::WA_DeleteOnClose);
//    dialog->open();

//    QColor color = QColorDialog::getColor(QColor(0, 0, 255), this, "颜色对话框");
//    qDebug() << color;

//    QString style = "background-color: rgb(" + QString::number(color.red()) + ", " + QString::number(color.green()) + ", "
//            + QString::number(color.blue()) + ");";

//    char style[1024] = { 0 };
//    sprintf(style, "background-color: rgb(%d, %d, %d);", color.red(), color.green(), color.blue());

//    ui->pushButton->setStyleSheet(style);

    QColorDialog* color = new QColorDialog(this);

    connect(ui->pushButton, &QPushButton::clicked, [=](){
        // 设置颜色对话框中颜色
        color->setCurrentColor(QColor(75, 75, 75));

        color->open();
    });
}

